package com.jinzhi.jzweb.controller.decrypt;

import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.DecryptDO;
import com.jinzhi.jzweb.domain.ExaminationResultsComDO;
import com.jinzhi.jzweb.pojo.VtatisticsVo;
import com.jinzhi.jzweb.strategy.decrypt.DecryptService;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/*
 *  @author : JingChangTian
 *  @date   : 2024/3/18 14:18
 *  @description : 赛场得分统计
 *
 */
@Controller
@Api(value = "解密管理", tags = {"解密管理"})
public class DecryptController {

    private final DecryptService decryptService;

    public DecryptController(DecryptService decryptService) {
        this.decryptService = decryptService;
    }





    @ApiOperation(value = "导入一次加密信息", notes = "导入一次加密信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "MultipartFile", value = "文件表格", required = true, dataType = "MultipartFile"),
            @ApiImplicitParam(name = "String", value = "赛场", required = true, dataType = "String"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/importExcelDecryptNum1")
    public Result<Object> importExcelDecryptNum1(@RequestParam("file") MultipartFile file, String field){
        return decryptService.importExcelDecryptNum1(file,field);
    }

    @ApiOperation(value = "导入二次加密信息", notes = "导入二次加密信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "MultipartFile", value = "文件表格", required = true, dataType = "MultipartFile"),
            @ApiImplicitParam(name = "String", value = "赛场", required = true, dataType = "String"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/importExcelDecryptNum2")
    public Result<Object> importExcelDecryptNum2(@RequestParam("file") MultipartFile file, @RequestParam("file")String field){
        return decryptService.importExcelDecryptNum2(file,field);
    }


    @ApiOperation(value = "修改解密信息", notes = "修改解密信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "decryptDO", value = "解密对象", required = true, dataType = "DecryptDO"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/updateDecrypt")
    public Result<Object> updateDecrypt(@RequestBody DecryptDO decryptDO){
        return decryptService.updateDecrypt(decryptDO);
    }


    @ApiOperation(value = "根据赛场查询已经匹配解密列表", notes = "根据赛场查询已经匹配解密列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "decryptDO", value = "解密对象", required = true, dataType = "DecryptDO"),
    })
    @ApiResponses({
            @ApiResponse(code = 0, message = "操作成功",response = DecryptDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/getDecrypt")
    public Result<Object> getDecrypt(@RequestBody DecryptDO decryptDO){
        return decryptService.getDecrypt(decryptDO);
    }


    @ApiOperation(value = "根据赛场查询未匹配解密列表", notes = "根据赛场查询未匹配解密列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "decryptDO", value = "解密对象", required = true, dataType = "DecryptDO"),
    })
    @ApiResponses({
            @ApiResponse(code = 0, message = "操作成功",response = DecryptDO.class),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/getAddDecrypt")
    public Result<Object> getAddDecrypt(@RequestBody DecryptDO decryptDO){
        return decryptService.getAddDecrypt(decryptDO);
    }




    @ApiOperation(value = " 导出根据赛场,类型导出解密信息", notes = " 导出根据赛场,类型导出解密信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "field", value = "赛场信息ABCD", required = true, dataType = "String"),
            @ApiImplicitParam(name = "type", value = "类型1:一次加密，2:二次加密3:一二次加密", required = true, dataType = "Integer"),
    })
    @ApiResponses({
            @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping(value = "/getAddDecrypt")
    public void downloadImportDecrypt(HttpServletResponse response, String field, Integer type){
        decryptService.downloadImportDecrypt(response,field,type);
    }


    @ApiOperation(value = "根据id删除解密信息", notes = "根据id删除解密信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "当前跳id", required = true, dataType = "Long"),
    })
    @ApiResponses({
            @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping(value = "/deltedDecrypt")
    public Result<Object> deltedDecrypt(Long id){
        return decryptService.deltedDecrypt(id);
    }
}
